package com.chinasoft.common;

import lombok.Data;

/**
 * 统一返回结果
 */
@Data
public class Result {
    private int code;//200   /400  /500
    private String msg;//成功 /失败
    private Long total;//总记录数
    private Object data;//数据
    //失败
    public static  Result fail(){
        return result(400,"失败",0L,null);
    }
    public static  Result fail(String msg){
        return result(400,msg,0L,null);
    }
    //成功
    public static  Result suc(){
        return result(200,"成功",0L,null);
    }
    public static  Result suc(Object data){
        return result(200,"成功",0L,data);
    }
    public static  Result suc(Object data,Long total){
        return result(200,"成功",total,data);
    }
    public static Result result(int code, String msg, Long total, Object data) {
        Result res = new Result();
        res.code = code;
        res.msg = msg;
        res.total = total;
        res.data = data;
        return res;
    }
}
